//
//  CGQlixianDetailTableViewCell.swift
//  SheYangBigData
//
//  Created by 叁拾叁 on 2021/5/11.
//  Copyright © 2021 叁拾叁. All rights reserved.
//

import UIKit

class CGQlixianDetailTableViewCell: SYBaseCell {

    var bgView: UIView = {
        let v = UIView()
        v.backgroundColor = .white
        v.layer.cornerRadius = 5
        return v
    }()
    let tiplab: UILabel = {
        let v = UILabel()
        v.text = "设备离线"
        v.font = 15.autoBoldFontSize()
        v.textColor = UIColor(hex: 0x333333)
        return v
    }()
    var lView: UIView = {
        let v = UIView()
        v.backgroundColor = UIColor(hex: 0xF0F0F0)
        return v
    }()
    
    
    
    
    let xiangmu: CGQlixianView = {
        let v = CGQlixianView()
        v.title.text = "项目名称："
        v.num.text = "龙南京六合龙池鲫鱼项目南京六合龙池鲫鱼项目南京六合龙池鲫鱼项目二氧化碳传感器已经离线，请立即处理鱼"
        return v
    }()
    
    let shebei: CGQlixianView = {
        let v = CGQlixianView()
        v.title.text = "设备名称："
        v.num.text = "南京六合龙池鲫鱼项目南京六合龙池鲫鱼项目南京六合龙池鲫鱼项目二氧化碳传感器已经离线，请立即处理"
        return v
    }()
    let shijian: CGQlixianView = {
        let v = CGQlixianView()
        v.title.text = "离线时间："
        v.num.text = "2021-04-19"
        return v
    }()
    let beizhu: CGQlixianView = {
        let v = CGQlixianView()
        v.title.text = "备注："
        
        v.num.text = "南京六合龙池鲫鱼项目南京六合龙池鲫鱼项目南京六合龙池鲫鱼项目二氧化碳传感器已经离线，请立即处理"
        return v
    }()
    
    public func configureMessageView(model:NSMessageRecordsModel){
        
        
        shijian.num.text = model.createDate ?? "暂无内容"
        beizhu.num.text = model.remarks ?? "暂无内容"
        shebei.num.text = model.deviceName ?? ""
        xiangmu.num.text = model.appName ?? ""
        
     
        
        
    }
    
    
    override func initViews() {
        self.backgroundColor = UIColor(hex: 0xF7F7F7)
        addSubview(bgView)
        bgView.addSubview(tiplab)
        bgView.addSubview(lView)
        bgView.addSubview(xiangmu)
        bgView.addSubview(shebei)
        bgView.addSubview(shijian)
        bgView.addSubview(beizhu)
        
        bgView.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(10.autoWidth())
            make.left.equalToSuperview().offset(autoWidth(10))
            make.right.equalToSuperview().offset(autoWidth(-10))
            make.bottom.equalToSuperview()
        }
        tiplab.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(19.autoWidth())
            make.left.equalToSuperview().offset(autoWidth(12))
            make.right.equalToSuperview().offset(autoWidth(-12))
        }
        lView.snp.makeConstraints { (make) in
            make.top.equalTo(tiplab.snp.bottom).offset(14.autoWidth())
            make.left.equalToSuperview().offset(autoWidth(0))
            make.right.equalToSuperview().offset(autoWidth(0))
            make.height.equalTo(0.5)
        }
        
        xiangmu.snp.makeConstraints { (make) in
            make.top.equalTo(lView.snp.bottom).offset(17.autoWidth())
            make.left.equalToSuperview().offset(autoWidth(12))
            make.right.equalToSuperview().offset(autoWidth(-15))
        }
        shebei.snp.makeConstraints { (make) in
            make.top.equalTo(xiangmu.snp.bottom).offset(17.autoWidth())
            make.left.equalToSuperview().offset(autoWidth(12))
            make.right.equalToSuperview().offset(autoWidth(-15))
        }
        shijian.snp.makeConstraints { (make) in
            make.top.equalTo(shebei.snp.bottom).offset(17.autoWidth())
            make.left.equalToSuperview().offset(autoWidth(12))
            make.right.equalToSuperview().offset(autoWidth(-15))
        }
        beizhu.snp.makeConstraints { (make) in
            make.top.equalTo(shijian.snp.bottom).offset(17.autoWidth())
            make.left.equalToSuperview().offset(autoWidth(12))
            make.right.equalToSuperview().offset(autoWidth(-15))
            make.bottom.equalToSuperview().offset(autoWidth(-17))
        }

    }


}


class CGQlixianView: SYBaseView {
    
    let title: UILabel = {
        let v = UILabel()
        
        v.font = 14.autoFontSize()
        v.textColor = UIColor(hex: 0x333333)
        v.textAlignment = .right
        return v
    }()
    
    var num: UILabel = {
        let v = UILabel()
        
        v.font = 14.autoFontSize()
        v.textColor = UIColor(hex: 0x666666)
        v.numberOfLines = 0
        return v
    }()
    
    
    
    override func initViews() {
        self.backgroundColor = .clear
        addSubview(title)
        addSubview(num)
        
        title.snp.makeConstraints { (make) in
            make.top.equalToSuperview()
            make.left.equalToSuperview()
            make.height.equalTo(13.autoWidth())
            make.width.equalTo(69.autoWidth())
        }
        num.snp.makeConstraints { (make) in
            make.top.equalToSuperview()
            make.right.equalToSuperview().offset(0)
            make.left.equalTo(title.snp.right).offset(16.autoWidth())
            make.bottom.equalToSuperview()
            make.height.greaterThanOrEqualTo(13.autoWidth())
        }
        
        
    }
}
